<template>
  <el-card class="box-card">
    <template #header>
      <div class="card-header">
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
          <el-form-item label="名字">
            <el-input v-model="formInline.user" placeholder="名字" clearable />
          </el-form-item>
          <el-form-item label="地址">
            <el-select
                v-model="formInline.region"
                placeholder="选择地址"
                label-width="120"
                clearable
            >
              <el-option label="shanghai" value="shanghai" />
              <el-option label="beijing" value="beijing" />
            </el-select>
          </el-form-item>
          <el-form-item label="时间">
            <el-date-picker
                v-model="formInline.date"
                type="date"
                placeholder="选择时间"
                clearable
            />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
    </template>
    <div class="text item">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="id" label="ID" width="180" />
        <el-table-column prop="name" label="名字" width="180" />
        <el-table-column prop="address" label="地址" />
        <el-table-column prop="date" label="时间" width="180" />

        <el-table-column fixed="right" label="操作" width="240">
          <template #default="scope">
            <el-button size="small" @click="handleClick()">编辑</el-button>
            <el-button size="small" type="danger">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <template #footer>
      <el-pagination background layout="prev, pager, next" :total="1000" />
    </template>
  </el-card>
</template>

<script setup>
import { reactive } from 'vue'

const formInline = reactive({
  user: '',
  region: '',
  date: '',
})

const onSubmit = () => {
  console.log('submit!')
}


const tableData = [
  {
    id: 1,
    date: '2016-05-03',
    name: 'Tom',
    address: 'beijing',
  },
  {
    id: 2,
    date: '2016-05-02',
    name: 'Tom',
    address: 'beijing',
  },
  {
    id: 3,
    date: '2016-05-04',
    name: 'Tom',
    address: 'shanghai',
  }
]

const handleClick = () => {
  console.log('click')
}
</script>

<style lang="less">
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-footer{
  text-align: right;
}

.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.demo-form-inline .el-input {
  --el-input-width: 220px;
}

.demo-form-inline .el-select {
  --el-select-width: 220px;
}

.el-pagination{
  justify-content: right;
}

</style>
